$(function () {
    window.testUrl = "http://m.kexuemihe.com"; //http://m.kexuemihe.com   //http://139.186.155.167
    /**  */
    window.sendAjax = function (methods, url, param) {
        return new Promise(function (resolve, reject) {
            $.ajax({
                type: methods,
                url: url,
                data: param,
                dataType: "json",
                // processData: false,
                success: function (data) {
                    resolve(data);
                },
                error: function (error) {
                    reject(error);
                }
            });
        })
    };
    /**扩展localstorage */
    //设置localStorage的值
    // extendLocalStorage.set("test", "你好", curTime + 10000);
    //获取localStorage的值
    // var localData = extendLocalStorage.get("test");
    window.extendLocalStorage = {
        set: function (key, value, ttl_ms) {
            var data = {
                value: value,
                expirse: new Date(ttl_ms).getTime()
            };
            localStorage.setItem(key, JSON.stringify(data));
        },
        get: function (key) {
            var data = JSON.parse(localStorage.getItem(key));
            if (data !== null) {
                if (data.expirse != null && data.expirse < new Date().getTime()) {
                    localStorage.removeItem(key);
                } else {
                    if (data.value) {
                        return data.value;
                    }
                    return data
                }
            }
            return null;
        }
    }
    /** 扩展localstorage结束 */
})